﻿$(function(){//延迟加载
	
	$('#jfrow').load('showjifangsec',function(){
		$.getScript('/xasj/js/component/jifangsec.js');
	});
	
	$('#dvfirm').combobox({
		onChange:function(newValue,oldValue){
			if(newValue==''){				
				$('#dvmodel').combobox({
					disabled:true
				});
			}else{
				$('#dvmodel').combobox({
					//value:'请选择',
					disabled:false,
					valueField:'dvmodelId',
					textField:'modelname',
					url:"showmodelsec?dvbelong=olt&dvfirmId="+newValue,
				});
			}
		}
	});
	
	$('#dvmodel').combobox({
		disabled:true,
		multiple:true,
		onChange:function(newValue,oldValue){
			if(newValue!=''){				
				$('#oltsec').datagrid('reload',{
					oltip:'',
					dvfirmId:'',
					dvmodelId:newValue,
					jfId:''
				});
			}
		}
	});
	
	$('#ponyujing').treegrid({
		title:'PON口预警',
		iconCls:'zzjg',
        nowrap: false,
        rownumbers: true,
        animate:true,
        collapsible:true,
        pageSize:20,
        url:'getponyujingjf',
        queryParams:{
        	
        },
		toolbar:'#tb',
        idField:'jfId',
        treeField:'jfname',
        pagination:true,
        columns:[[{
        	title:'机房名称',
        	field:'jfname',
        	width:'45%',
        },{
        	title:'总共pon口数',
        	field:'oltponnum',
        	width:'25%'
        },{
        	title:'可用pon口数',
        	field:'oltuseponnum',
        	width:'25%'
        }]],
        onBeforeExpand:function(row){
	    	var cnode=$('#ponyujing').treegrid('getChildren',row.jfId);
	    	if(cnode!=''){
		    	for(var i=0;i<cnode.length;i++){
		    		$('#ponyujing').treegrid('remove',cnode[i].jfId);
		    	}		    			
	    	}
			$.ajax({
				url:'extendponyujing?nodeId='+row.jfId,
				success:function(data){
					$('#ponyujing').treegrid('append', {
						parent: row.jfId,
						data:data
					});
				}
			});
		},
        onLoadSuccess:function(data){
        	
        }
	});
	
	
	$('#searchres').linkbutton({
		width:'280px',
		hwight:'30px',
		iconCls:'icon-search',
		onClick:function(){
			var fuxuan='';
			var danxuan='';	
			var jcode='';
			var jId='';
			if($('#dajuxiang').combobox('getValue')!=''){
				jId=$('#dajuxiang').combobox('getValue');
				jcode='djxId';
				if($('#juxiang').combobox('getValue')!='请选择'&&$('#juxiang').combobox('getValue')!=''){
					jId=$('#juxiang').combobox('getValue');
					jcode='jxId';
					if($('#jifang').combobox('getValue')!='请选择'&&$('#jifang').combobox('getValue')!=''){
						jId=$('#jifang').combobox('getValue');
						jcode='jfId';
					}
				}
				danxuan=danxuan+jcode+','+jId;
			}
			
			$('select[textboxname=fuxuan]').each(function(){
				var fuxuanvalues=$(this).combobox('getValues').toString();
				var ffield=$(this).data('code');
				if(fuxuanvalues!=''){
					if(fuxuan.length==0){
						fuxuan=ffield+','+fuxuanvalues;
					}else
						fuxuan=fuxuan+":"+ffield+','+fuxuanvalues;
				}
			});
			
			$('select[textboxname=danxuan]').each(function(){
				var danxuanvalues=$(this).combobox('getValues').toString();
				var ffield=$(this).data('code');
				if(danxuanvalues!=''){
					if(danxuan.length==0){
						danxuan=ffield+','+danxuanvalues;
					}else
						danxuan=danxuan+":"+ffield+','+danxuanvalues;
				}
			});
			
//			alert(danxuan);
//			alert(fuxuan);
			
			$('#ponyujing').treegrid('reload',{
				danxuan:danxuan,
				fuxuan:fuxuan
			});
			
		}
	});
	
	
	$('#exthis').linkbutton({
		width:'150px',
		height:'24px',
		iconCls:'icon-ok',
		onClick:function(){
			
		}
	});
	$('#exall').linkbutton({
		width:'150px',
		height:'24px',
		iconCls:'icon-redo',
		onClick:function(){
			
		}
	});
	$('#exallolt').linkbutton({
		width:'150px',
		height:'24px',
		iconCls:'icon-zzjg',
		onClick:function(){
			
		}
	});
	$('#daying').linkbutton({
		width:'150px',
		height:'24px',
		iconCls:'icon-save',
		onClick:function(){
			
		}
	});
});